package cn.xuguowen.user.designPatten.factory.heima_factory_method;

/**
 * ClassName: CoffeeStore
 * Package: cn.xuguowen.user.designPatten.factory.heima_factory_method
 * Description:
 * 咖啡商店，提供订购咖啡的方法
 * @Author 徐国文
 * @Create 2023/4/25 18:13
 * @Version 1.0
 */
public class CoffeeStore {
    // 依赖于抽象，而不是具体，满足依赖倒置原则
    private CoffeeFactory coffeeFactory;

    public CoffeeStore(CoffeeFactory coffeeFactory) {
        this.coffeeFactory = coffeeFactory;
    }

    public void setCoffeeFactory(CoffeeFactory coffeeFactory) {
        this.coffeeFactory = coffeeFactory;
    }

    // 订购咖啡的方法
    public Coffee orderCoffee() {
        Coffee coffee = coffeeFactory.createCoffee();
        coffee.addSugar();
        coffee.addMilk();
        return coffee;
    }
}
